package com.xiaok.mobileredis.service.impl;

import cn.hutool.core.date.DateUtil;
import com.xiaok.mobileredis.entity.SensitiveWord;
import com.xiaok.mobileredis.mapper.SensitiveWordMapper;
import com.xiaok.mobileredis.service.SensitiveWordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Classname SensitiveWordServiceImpl
 * @Description TODO
 * @Date 2020/9/20 22:03
 * @Created by xiaok
 */
@Service
public class SensitiveWordServiceImpl implements SensitiveWordService {
    @Autowired
    SensitiveWordMapper sensitiveWordMapper;


    @Override
    public Integer add(SensitiveWord sensitiveWord) {
        sensitiveWord.setIsActive(1);
        sensitiveWord.setCreateTime(DateUtil.date());
        //Integer insert = sensitiveWordMapper.insert(sensitiveWord);
        Integer insert = sensitiveWordMapper.addOfSql(sensitiveWord);

        
        return insert;
    }

    @Override
    public void delete(Integer id) {
        sensitiveWordMapper.deleteByIdOfSql(id);
       // sensitiveWordMapper.deleteById(id);//通过mybatis实现
    }

    @Override
    public boolean update(SensitiveWord sensitiveWord) {
        //Integer integer = sensitiveWordMapper.updateById(sensitiveWord);
        Integer integer = sensitiveWordMapper.updateOfSql(sensitiveWord);
        return integer>0 ?true :false;
    }

    @Override
    public List<SensitiveWord> selectlist() {
        List<SensitiveWord> sensitiveWords = sensitiveWordMapper.selectListOfSql(1, 2); //通过写sql语句实现
       // List<SensitiveWord> sensitiveWords = sensitiveWordMapper.selectList(null); //通过mybatis实现
        return sensitiveWords;
    }


}
